%% 
%% This is file `lgrind.sty' generated
%% on <1991/9/13> with the docstrip utility (v1.1l test). 
%% 
%% The original source file was `lgrind.doc'.
%% 
%% 
%% lgrind is a minor adaptation of Jerry Leichter's tgrind for LaTeX, 
%% which was a notable improvement upon Van Jacobsen's tgrind for 
%% plain TeX, which was adapted from vgrind, a troff prettyprinter. 
%% 
%% LaTeX lgrind environment

\newif\ifc@mment %True when setting a comment
\newif\ifstr@ng %True when setting a string constant
\newif\ifright@ %In comments, \" => '' (else ``)
\newif\ifLGd@fault %True after default \LGbegin
\newcount\lc@unt %Line counter
\newcount\ln@xt %Next line to get numbered
\newbox\ls@far %Stores lines so far for tabbing
\newdimen\TBw@d %Tabwidth when tabbing
\newbox\tb@x %Tab positioning
\newdimen\@ts %Width of listing space
{\catcode`\_=\active \gdef\@setunder{\let_=\sp@ce}}

\def\BGfont{\sf} %"Background" font
\def\CMfont{\rm} %Comment font
\def\KWfont{\bf} %Keyword font
\def\STfont{\tt} %String font
\def\VRfont{\it} %Variable name font
\def\LGsize{\small} %Size to use in displayed code
\def\LGfsize{\footnotesize} %Size to use in \lgrindfile
\newif\ifLGinline %True for in-line code
\newif\ifLGleftnum %Put line numbers on the left
\newcount\LGnuminterval %Line numbering interval
\LGnuminterval=10
\newskip\LGindent %Indentation for displayed lines
\LGindent=1.6667\parindent
\def\LGbegin{\ifLGinline$\hbox\else$$\vbox\fi\bgroup\LGd@faulttrue}
\def\LGend{\ifLGd@fault\egroup\ifLGinline$\else$$\fi\LGd@faultfalse\fi}

\def\lgrind{%
\def\Line##1{\L{\LB{##1}}}% %For use with %=
\let\Head=\@gobble %Header information (-h)
\def\File##1,##2,##3{}% %File specification info
\let\Proc=\@gobble %Marks procedure def beginning
\let\ProcCont=\@gobble %Marks end of nested procedure def
\def\NewPage{\filbreak\bigskip}%
\ifLGinline
 \def\L##1{\setbox\ls@far\null\CF\strut##1\ignorespaces}%
\else
 \let\r@ghtlno\relax\let\l@ftlno\relax
 \ifnum\LGnuminterval>\z@
  \ifLGleftnum
   \def\l@ftlno{\ifnum\lc@unt>\ln@xt\global\advance\ln@xt by\LGnuminterval
     \llap{{\scriptsize\the\lc@unt\quad}}\fi}%
  \else
  \def\r@ghtlno{\ifnum\lc@unt>\ln@xt\global\advance\ln@xt by\LGnuminterval
     \rlap{{\scriptsize\enspace\the\lc@unt}}\fi}%
  \fi
 \fi
 \def\L##1{\@@par\setbox\ls@far=\null\CF\strut
  \global\advance\lc@unt by1%
  \hbox to\hsize{\hskip\LGindent\l@ftlno ##1\hfil\r@ghtlno}\ignorespaces}%
\fi
\lc@unt=0\ln@xt=\LGnuminterval\advance\ln@xt by-1%
\def\LB{\CF\hbox\bgroup\box\ls@far\let\next=}%
\def\Tab##1{\setbox\tb@x=\lastbox\TBw@d=\wd\tb@x\advance\TBw@d by 1\@ts
 \ifdim\TBw@d>##1\@ts
  \setbox\ls@far=\hbox{\box\ls@far \box\tb@x \sp@ce}\else
  \setbox\ls@far=\hbox to ##1\@ts{\box\ls@far \box\tb@x \hfil}\fi\LB}%
\ifLGinline\def\sp@ce{\hskip .3333em}%
\else \setbox\tb@x=\hbox{{\tt 0}}\@ts=\wd\tb@x \def\sp@ce{\hskip 1\@ts}\fi
\catcode`\_=\active \@setunder
\let\CF=\BGfont
\def\K##1{{\KWfont ##1}\global\futurelet\next\ic@r}% %Keyword
\def\V##1{{\VRfont ##1}\global\futurelet\next\ic@r}% %Variable
\def\ic@r{\let\@tempa\/\ifx.\next\let\@tempa\relax% %Optional \/
 \else\ifx,\next\let\@tempa\relax\fi\fi\@tempa}%
\def\C{\CMfont \global\let\CF\CMfont \global\c@mmenttrue \global\right@false}%
\def\CE{\BGfont \global\let\CF\BGfont \global\c@mmentfalse}%
\def\S{\STfont \global\let\CF\STfont \global\str@ngtrue}%
\def\SE{\BGfont \global\let\CF\BGfont \global\str@ngfalse}%
\def\,{\relax \ifmmode\mskip\thinmuskip \else\thinspace \fi}%
\def\!{\relax \ifmmode\mskip-\thinmuskip \else\negthinspace \fi}%
\def\CH##1##2##3{\relax\ifmmode ##1\relax
\else\ifstr@ng ##2\relax\else$##3$\fi\fi }%
\def\{{\CH\lbrace {\char'173}\lbrace }%
\def\}{\CH\rbrace {\char'175}\rbrace }%
\def\1{\CH///}% %/
\def\2{\CH\backslash {\char'134}\backslash }% %\
\def\|{\CH|{\char'174}|}%
\def\<{\CH<<<}%
\def\>{\CH>>>}%
\def\*{\CH***}\relax %\relax for DOCSTY
\def\-{\CH---}%
\def\_{\ifstr@ng {\char'137}\else
  \leavevmode \kern.06em \vbox{\hrule width.35em}%
  \ifdim\fontdimen\@ne\font=\z@ \kern.06em \fi\fi }%
\def\&{{\sf \char'046}}%
\def\#{{\STfont \char'043}}%
\def\%{{\char'045}}%
\def\~{{\char'176}}%
\def\"{\ifc@mment\ifright@ ''\global\right@false \else``\global\right@true \fi
   \else{\tt \char'042}\fi}%
\def\'{\ifc@mment'\else {\tt \char'015}\fi}%
\def\^{{\tt \char'136}}%
\def\${{\ifmmode\sl\else\ifdim\fontdimen\@ne\font>\z@\sl\fi\fi
  \char'044}}% %No $ in \it, use \sl
\parindent\z@\parskip\z@ plus 1pt\hsize\linewidth%
}
\def\endlgrind{\@@par}
\def\lgrinde{\ifLGinline\else\LGsize\fi\begin{lgrind}}
\def\endlgrinde{\end{lgrind}}

\def\lagrind{\@ifstar{\@slagrind}{\@lagrind}}

\def\@lagrind{\@ifnextchar[{\@@lagrind}{\@@lagrind[t]}}
\def\@slagrind{\@ifnextchar[{\@@slagrind}{\@@slagrind[t]}}

\def\@@lagrind[#1]#2#3#4{%
    \begin{figure}[#1]
\hrule
\vskip .5\baselineskip
\begin{minipage}\columnwidth\LGsize\LGindent\z@
    \begin{lgrind}
\input #2\relax
    \end{lgrind}
\end{minipage}
\vskip .5\baselineskip plus .5\baselineskip
\begingroup
    \setbox\z@=\hbox{#4}%
    \ifdim\wd\z@>\z@
\caption{#3}%
\label{#4}%
    \else
\captcont{#3}%
    \fi
\endgroup
\vskip 2pt
\hrule
    \end{figure}
}

\def\@@slagrind[#1]#2#3#4{%
    \begin{figure*}[#1]
\hrule
\vskip .5\baselineskip
\begin{minipage}\textwidth\LGsize\LGindent\z@
    \begin{lgrind}
\input #2\relax
    \end{lgrind}
\end{minipage}
\vskip .5\baselineskip plus .5\baselineskip
\begingroup
    \setbox\z@=\hbox{#4}%
    \ifdim\wd\z@>\z@
\caption{#3}%
\label{#4}%
    \else
\captcont{#3}%
    \fi
\endgroup
\vskip 2pt
\hrule
    \end{figure*}
}

\def\lgrindfile#1{%
    \par\addvspace{0.1in}
    \hrule
    \vskip .5\baselineskip
    \begingroup\LGfsize\LGindent\z@
\begin{lgrind}
    \input #1\relax
\end{lgrind}
    \endgroup
    \vskip .5\baselineskip
    \hrule
    \addvspace{0.1in}
}

\endinput
%% 
%% End of file `lgrind.sty'.
